package edu.nf.relaxenjoy.common.exception;

import java.util.Arrays;

/**
 * @author zhu
 * @date 2024-12-11
 */
public class CommonException extends RuntimeException{

    private Integer code;

    public CommonException(String message, Integer code) {
        super(message);
        this.code = code;
    }

    public CommonException(Integer code, String... message) {
        super(Arrays.toString(message));
        this.code = code;
    }

    public CommonException(String message) {
        super(message);
        this.code = ErrorsEnum.FAIL.errorCode();
    }

    public CommonException(ErrorsEnum errorsEnum) {
        super(errorsEnum.errorMessage());
        this.code = errorsEnum.errorCode();
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public Integer getCode() {
        return code;
    }
}
